package com.cloudlead.common.lang.api;

import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

import com.fasterxml.jackson.annotation.JsonIgnore;

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class AbstractActionResponse implements ActionResponse {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7142693914554226739L;

	/**
	 * 执行是否成功
	 */
	protected boolean success;
	/**
	 * 消息级别
	 */
	protected Level level;

	/**
	 * 耗时
	 */
	protected long takeTime;

	protected String requestId;

	protected int code;

	@JsonIgnore
	protected Map<String, String> headers;

	protected AbstractActionResponse() {
		super();
		this.success = true;
		this.level = Level.info;
		this.headers = new HashMap<>();
	}

	protected AbstractActionResponse(boolean success, Level level) {
		super();
		this.success = success;
		this.level = level;
		this.headers = new HashMap<>();
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Level getLevel() {
		return level;
	}

	public void setLevel(Level level) {
		this.level = level;
	}

	public long getTakeTime() {
		return takeTime;
	}

	public void setTakeTime(long takeTime) {
		this.takeTime = takeTime;
	}

	public String getRequestId() {
		return requestId;
	}

	public void setRequestId(String requestId) {
		this.requestId = requestId;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public Map<String, String> getHeaders() {
		return headers;
	}

}
